/* jshint esversion: 6 */
const Router = require('koa-router');
const tool = require("../../tools/tool");
const router = new Router();
const {db} = require("../../models/db");
// 修改密码
router.post('/user/resetPwd', async ctx => {
    let id = ctx.request.body.id
    if(id) {
        let model = await db.models['admin'].findOne({
            where: {
                tenantId: ctx.user.tenantId,
                id
            }
        })
        model.userpwd = tool.crypto.MD5('12321')
        await model.save()
        return  ctx.suc('已更新密码为 【12321】')
    }
    else {
        return ctx.err('请输入密码')
    }
})

module.exports = router;